import React from 'react';

//请求地址ip统一配置
export const URLprefix = '';
//延迟
export function delay(timeout){
  var pro = new Promise(function(resolve,reject){
    setTimeout(resolve, timeout);
  });
  return pro;
}

//截取小数点
export function decimalsSwitch(str,num){
    str = str.toString().split('.');
    if(!!str[1]){
        str = str[0] +'.'+ str[1].substr(0,num);
    }else{
        str = str[0];
    }
    return str;
}
//整理参数
export function getBaicPostData(postdata={}){
    return {
        authParam:{
            // tenantId:'377ec8c660f74f95a13f059049877fcb'
            tenantId: getArg('tenantId')
        },
        param:{
            ...postdata
        },
        reqMethod:{
            isJsonP:1
        }
    }
}

export function whetherIs(type,obj) {
    switch(type){
        case 'array':
            return Object.prototype.toString.call(obj) === '[object Array]';
        break;
        case 'object':
            return Object.prototype.toString.call(obj) === '[object Object]';
        break;
        case 'function':
            return typeof(obj) === 'function';
        break;
    }
}
